package com.eva.androidlibrary.api.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 用户实体
 *
 * @author GUXIA318
 * @date 2015-09-23 16:08
 */
public class UserInfo extends BaseBean implements Parcelable {

    /** 已认证 */
    public static final int AUTH_STATUS_YES = 1;
    /** 未认证 */
    public static final int AUTH_STATUS_NO = 0;
    /** 审核中 */
    public static final int AUTH_STATUS_ING = 2;

    /** 用户UUID */
    private String uuid;

    /** 用户token */
    private String token;

    /** 昵称 */
    private String nickname;

    /** 真实姓名 */
    private String realname;

    /** 头像 */
    private String avatar;

    /** 手机号 */
    private String phone = "";

    /** 用户邮箱 */
    private String email = "";

    /** 是否实名认证，1：是，0：否 */
    @JSONField(name = "is_realname")
    private int isRealName;

    /** 是否快递员账号，1：是，0：否 */
    @JSONField(name = "is_courier")
    private int isCourier;

    /** 是否商家账号，1：是，0：否 */
    @JSONField(name = "is_merchant")
    private int isMerchant;

    /** 是否首次登陆，1：是，0：否 */
    @JSONField(name = "is_firstlogin")
    private int isFirstLogin;

    public UserInfo() {}

    public UserInfo(String id, String token) {
        this.uuid = id;
        this.token = token;
    }

    public String getUUID() {
        return uuid;
    }

    public void setUUID(String uuid) {
        this.uuid = uuid;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getIsRealName() {
        return isRealName;
    }

    public void setIsRealName(int isRealName) {
        this.isRealName = isRealName;
    }

    public int getIsCourier() {
        return isCourier;
    }

    public void setIsCourier(int isCourier) {
        this.isCourier = isCourier;
    }

    public int getIsMerchant() {
        return isMerchant;
    }

    public void setIsMerchant(int isMerchant) {
        this.isMerchant = isMerchant;
    }

    public int getIsFirstLogin() {
        return isFirstLogin;
    }

    public void setIsFirstLogin(int isFirstLogin) {
        this.isFirstLogin = isFirstLogin;
    }

    /**
     * 是否实名认证
     * @return
     */
    public boolean isCertification() {
        return this.isRealName == AUTH_STATUS_YES;
    }

//    /**
//     * 是否首次登录
//     * @return
//     */
//    public boolean isFirstLogin() {
//        return isFirstLogin == 1;
//    }
//
//
//    /**
//     * 是否快递员账号
//     *
//     * @return
//     */
//    public boolean isCourier() {
//        return isCourier == 1;
//    }
//
//    /**
//     * 是否商家账号
//     * @return
//     */
//    public boolean isMerchant() {
//        return isMerchant == 1;
//    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.uuid);
        dest.writeString(this.token);
        dest.writeString(this.nickname);
        dest.writeString(this.realname);
        dest.writeString(this.avatar);
        dest.writeString(this.phone);
        dest.writeInt(this.isRealName);
        dest.writeInt(this.isCourier);
        dest.writeInt(this.isMerchant);
        dest.writeInt(this.isFirstLogin);
    }

    protected UserInfo(Parcel in) {
        this.uuid = in.readString();
        this.token = in.readString();
        this.nickname = in.readString();
        this.realname = in.readString();
        this.avatar = in.readString();
        this.phone = in.readString();
        this.isRealName = in.readInt();
        this.isCourier = in.readInt();
        this.isMerchant = in.readInt();
        this.isFirstLogin = in.readInt();
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };

    @Override
    public String toString() {
        return "User: uuid = " + uuid + " , token = " + token;
    }
}
